﻿using System;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using QuickTest.Core.TestRunner;

namespace QuickTest.Tests.Core.TestRunner
{
    [TestFixture]
    public class TestResultTests
    {
        [Test]
        public void Can_Get_ResultState()
        {
            var result = new TestResult(String.Empty, ResultState.Success);

            Assert.That(result.ResultState, Is.EqualTo(ResultState.Success), "Should set ResultState");
        }

        [Test]
        public void Can_Get_IsSuccess()
        {
            var result = new TestResult(String.Empty, ResultState.Success);

            Assert.That(result.IsSuccess, "IsSuccess should be true");
            Assert.That(!result.IsFailure, "IsFailure should be false");
        }

        [Test]
        public void Can_Get_IsFailure()
        {
            var result = new TestResult(String.Empty, ResultState.Failure);

            Assert.That(!result.IsSuccess, "IsSuccess should be false");
            Assert.That(result.IsFailure, "IsFailure should be true");
        }

        [Test]
        public void Can_Get_Executed()
        {
            var result = new TestResult(String.Empty, ResultState.Success);

            Assert.That(result.Executed, "Executed should be true");
        }

        [Test]
        public void Can_Get_NotExecuted()
        {
            var result = new TestResult(String.Empty, ResultState.NotRun);

            Assert.That(!result.Executed, "Executed should be false");
            Assert.That(!result.IsSuccess, "IsSuccess should be false");
            Assert.That(!result.IsFailure, "IsFailure should be false");
        }

        [Test]
        public void Can_Get_Test_Name()
        {
            var result = new TestResult("MyTestName", ResultState.Failure);

            Assert.That(result.TestName, Is.EqualTo("MyTestName"), "Should get test name");
        }

        [Test]
        public void Can_Get_Failed_ToString()
        {
            var result = new TestResult("MyTestCase", ResultState.Failure);

            Assert.That(result.ToString(), Is.EqualTo("MyTestCase... failed"), "Should get string representation of Failure test result");
        }

        [Test]
        public void Can_Get_NotRun_ToString()
        {
            var result = new TestResult("MyTestCase", ResultState.NotRun);

            Assert.That(result.ToString(), Is.EqualTo("MyTestCase... not executed"), "Should get string representation of NotRun test result");
        }
    }
}